<template>
    <div class="transfer">
        <van-picker
                show-toolbar
                :title="palaceName"
                :columns="columns"
                @cancel="onCancel"
                @confirm="onConfirm"
                @change="onChange"
        ></van-picker>

    </div>
</template>

<script>
    import {Picker, Toast} from 'vant';

    export default {
        components: {
            [Picker.name]: Picker,
            [Toast.name]: Toast
        },
        props: {
            palaceName: {
                type: String,
                default: ''
            },
            value: {
                type: Number,
                default: null
            },
            cascaderOption: {
                type: Array,
                default: () => {
                    return []
                }
            }
        },
        data() {
            return {
                columns: [],
                myValue: null
            }
        },
        mounted() {
            console.info('cascaderOption', this.cascaderOption);
        },
        watch: {
            value: function (value) {
                this.myValue = this.value;
            },
            myValue: function (value) {
                this.$emit('input', this.myValue);
            }
        },
        methods: {
            onChange(picker, values) {
                if (citys[values[0]]) {
                    console.info('values', values);
                    picker.setColumnValues(1, Object.keys(citys[values[0]]));
                    // picker.setColumnValues(2, citys[values[0]][values[1]]);
                }

                // picker.setColumnValues(2, citys[values[0]]);
            },
            onConfirm(value, index) {
                console.info('value', value);
                // this.myValue = value.id;
                // this.$emit('selectSiteName',value.text);
            },
            onCancel() {
                this.$emit('closeActionSheet');
            }
        }
    }
</script>

<style scoped>
    /*.transfer {*/
    /*text-align: center;*/
    /*}*/
</style>
